package com.gla.dao;

import com.gla.domain.Order;
import com.gla.domain.OrderDetail;
import com.gla.domain.OrderDetailResponse;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {

    public List<OrderDetailResponse> selectOrderDetailByOrderId(Integer order_id);

    public List<Order> select(Map<String,Object> map);

   public void insertOrder(Order order);

    @Insert("INSERT INTO ORDERDETAIL (number,order_id,commodity_id) VALUES(#{number},#{order_id},#{commodity_id})")
    public void insertOrderDetail(OrderDetail orderDetail);

    @Delete("DELETE FROM ORDERS WHERE id=#{id}")
    public void deleteOrderById(Integer order_id);

    @Delete("DELETE FROM ORDERDETAIL WHERE order_id=#{order_id}")
    public void deleteOrderDetailByOrderId(Integer order_id);

    @Update("UPDATE ORDERS SET state=#{state} WHERE id=#{order_id}")
    void updateStatus(Integer order_id, Integer state);
}
